#include <stdio.h>
#include <string.h>
int insert(int *nums,int start, int end, int val){
    for(int it1 = start; it1 <= end ; ++it1 ){
        if(val < nums[it1]){
            for(int it2 = end; it2 >= it1 ; --it2 ){
                nums[it2+1] = nums[it2]; 
            }
            nums[it1] = val;
            return it1;
        }
    }
    nums[end+1] = val;
    return end+1;
}
void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n){
    int it = 0;
    for(int i = 0; i < n; ++i){
        for(int it1 = it; it1 <= m-1+i ; ++it1 ){
            if(nums2[i] < nums1[it1]){
                for(int it2 = m-1+i; it2 >= it1 ; --it2 ){
                    nums1[it2+1] = nums1[it2]; 
                }
                nums1[it1] = nums2[i];
                break;
            }
        }
        nums1[m+i] = nums2[i];
    }
}

int main(){
    int m = 3, n = 3;
    int nums1[m+n] = {1,2,3,0,0,0};
    int nums2[n] = {4,5,6};
    merge(nums1,m+n,m,nums2,n,n);

    for(int i=0; i < m + n; i++){
        printf("%d ",nums1[i]);
    }
    printf("\n");
    return 0;
}
/*
插入时, 需要移动大部分元素
*/
